package cn.dengta.webapp.risk.config;

import cn.dengta.common.util.SpringUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 数美风控参数配置
 */
@Component
@Getter
@Setter
@ConfigurationProperties(prefix = "webapp.sm")
public class SmConfig implements InitializingBean {

	String accessKey;
	/** 密钥 **/
	String secret;

	static SmConfig config;

	public static SmConfig get() {
		SmConfig cfg = config;
		if (cfg == null) {
			config = cfg = SpringUtil.getBean(SmConfig.class);
		}
		return cfg;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
		// 尽量自己初始化，避免 Context Refresh 导致的异常
		config = this;
	}

}
